//
//  Tools.m
//  MyBook
//
//  Created by zhiyou on 16-3-19.
//  Copyright (c) 2016年 zhiyou. All rights reserved.
//

#import "Tools.h"
#import "MainVC.h"
#import "PersonVC.h"
#import "PHVC.h"
@implementation Tools
+ (FMDatabase *)getDatabase
{
    // 存放数据库的路径
    NSString * path = [NSHomeDirectory() stringByAppendingString:@"/Documents/database.sqlite"];
    NSLog(@"%@",path);
    // 创建数据库对象
    FMDatabase * db = [[FMDatabase alloc] initWithPath:path];
    // 调用open,如果文件路径下有数据库文件,只做打开操作
    if([db open])
    {
        NSLog(@"数据库打开成功");
    }else
    {
        // 断言
        NSAssert(NO, @"数据库打开失败");
    }
    
    return db;
}
+(void)goToMainVC
{
    MainVC * vc1 = [[MainVC alloc]init];
    PHVC*vc2=[[PHVC alloc]init];
    PersonVC * vc3= [[PersonVC alloc]init];
  
    UINavigationController * nav1 = [[UINavigationController alloc]initWithRootViewController:vc1];
    nav1.navigationBar.tintColor=[UIColor cyanColor];
    UINavigationController * nav2 = [[UINavigationController alloc]initWithRootViewController:vc2];
    nav2.navigationBar.tintColor=[UIColor cyanColor];
    UINavigationController * nav3 = [[UINavigationController alloc]initWithRootViewController:vc3];
    nav3.navigationBarHidden = YES;
//    UINavigationController * nav4 = [[UINavigationController alloc]initWithRootViewController:vc4];
    vc1.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"主页" image:[UIImage imageNamed:@"main@2x"] selectedImage:nil];
    vc2.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"排行榜" image:[UIImage imageNamed:@"news@2x"] selectedImage:nil];
//    vc3.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"文件" image:[UIImage imageNamed:@"file@2x"] selectedImage:nil];
    vc3.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"个人" image:[UIImage imageNamed:@"person@2x"] selectedImage:nil];
    UITabBarController * tabBar = [[UITabBarController alloc]init];
    tabBar.viewControllers = @[nav1,nav2,nav3];
    UIWindow * window = [UIApplication sharedApplication].delegate.window;
    window.rootViewController = tabBar;
}

@end
